package org.kosta.android.samples.part1;

import org.kosta.android.samples.KostaAndroidSampleActivity;
import org.kosta.android.samples.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;

public class ViewSamplesActivity extends Activity {
	
	private Button mBtn;
	private ImageButton mImageBtn;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view_sample_layout);
        
        mImageBtn = (ImageButton)findViewById(R.id.top_left_button);
        mImageBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
        
        mBtn = (Button)findViewById(R.id.top_right_button);
        mBtn.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(v.getContext(), KostaAndroidSampleActivity.class);
				//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});
        
        CheckBox mCheckbox = (CheckBox)findViewById(R.id.sampleCheckBox);
        mCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
				if(isChecked)
					Toast.makeText(ViewSamplesActivity.this, "체크됨", Toast.LENGTH_SHORT).show();
				else
					Toast.makeText(ViewSamplesActivity.this, "체크해제됨", Toast.LENGTH_SHORT).show();
			}
		});
    }
}